<?php
  require_once('tpl/header.php');
?><?php 
      require_once("loginCheckadmin.php");
      require_once("../system/dbConn.php");
 
     ?>
  <form action="">
    	<input type="text" name="key">
    	<input type="submit" value="搜索">
    </form>


	<?php 
	//连接数据库：读取users表中的所有记录，显示到表格中



	$sql = "select * from 0goods ";
    
    if(isset($_GET["key"])){ 
       $key=trim($_GET["key"]);
       $sql="select * from 0goods where gname like '%{$key}%'";
    }
    
	$result = mysqli_query($link,$sql);
;//结果集
	$num = mysqli_num_rows($result);
	if($num==0){
		echo "没有记录，请重新输入";
		exit();
	}
	?>
	<table class="table table-bordered" align="center" width="60%">
		<caption>商品信息列表（共 <?php echo $num ?> 个商品）</caption>
		<tr>
			<th width="5%">商品编号</th>
			<th width="15%">商品名称</th>
			<th width="10%">商品类型</th>
			<th width="10%">商品价格</th>
			<th width="10%">商品照片</th>
			<th width="10%">上传时间</th>
			<th width="10%">出售人</th>
			<th width="10%">备注</th>
			<th width="10%">手机号码</th>
			<th width="10%">操作</th>
		</tr>
	<?php
	while ($row = mysqli_fetch_assoc($result)) {
	?>
		<tr >
			<th ><?php echo $row["gid"]; ?></th>
			<th ><?php echo $row["gname"] ?></th>
				<th>
				<?php 
				// echo $row["gender"];
				if ($row["type"] == 0) {
					echo "生活用品";
				}else if ($row["type"] == 1){
					echo "电子产品";
				}else if ($row["type"] == 2){
					echo "学习资料";
				}else echo "其他";
				?>		
			</th>
			<th ><?php echo $row["price"] ?></th>
		<th><img src="../images/<?php echo $row["pic"] ?>" alt="头像" width="80" height="80"></th>
			<th ><?php echo $row["time"] ?></th>
			<th ><?php echo $row["uploaduser"] ?></th>
			<th ><?php echo $row["detial"] ?></th>
			<th ><?php echo $row["phone"] ?></th>
			<th ><a href="goodsUpper.php?gid=<?php echo $row["gid"];?>">上架</a> | <a href="do0ShopDelete.php?gid=<?php echo $row["gid"];?>" onclick="return confirm('真的删除吗?')">
			拒绝</a></th>
		</tr>
	<?php	
	}
	 	?>
		</table>
	</form>
   


<?php
  require_once('tpl/footer.php');
?>